package threading;


class MyThread extends Thread {

    @Override
    public void run() {
        while (true) {
            System.out.println("hello thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

//多线程
public class Demo1 {

    public static void main(String[] args) {

        MyThread t = new MyThread();
        t.start();//启用一个线程 来执行Tread中的run方法s
        while (true) {
            System.out.println("hello main!");
            try {
                    Thread.sleep(1000);
            } catch (InterruptedException e) {
                    e.printStackTrace();
            }

        }
    }

}
